package com.yunfeng.feign;

import com.yunfeng.feign.client.GreetingClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@RestController
public class FeignServiceApplication {
    @Autowired
    private GreetingClient greetingClient;

	public static void main(String[] args) {

	    SpringApplication.run(FeignServiceApplication.class, args);
	}

	@RequestMapping("/hello")
	public String sayHello (
	        @RequestParam(value = "name", defaultValue = "路人甲") String name) {
        String greetingWord = greetingClient.greetingWord();
        return String.format("%s:%s", greetingWord, name);
    }
}
